package com.lib.mapper;

import com.github.pagehelper.Page;
import com.lib.pojo.DTO.PageDTO;
import com.lib.pojo.VO.CategoryVO;
import com.lib.pojo.entity.BookInformation;
import com.lib.pojo.entity.Category;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CategoryMapper {
    //1：根据分类ID查询图书
    List<CategoryVO> getCategoryById(Integer categoryId);

    //2:根据id删除分类
    void delete(Integer categoryId);

    //3:新增分类
    void addCategory(Category category);

    //4:启用、禁用分类   5：修改分类信息
    void putCategory(Category category);

    //2：用户端-返回分类名称及ID
    List<Category> getCategoryName();

    //6：分类分页查询
    Page<Category> page(PageDTO pageDTO);
    Page<Category> pageAll(PageDTO pageDTO);

    //7：根据分类ID查询一个分类
    @Select("select * from library.bookcategory where category_id = #{id}")
    Category getById(Integer id);

    //判断这个分类关联的是否有图书
    @Select("select * from library.book_category_infor where category_id = #{id}")
    List<BookInformation> getByCategoryId(Integer id);
    @Select("select * from bookinformation")
    List<CategoryVO> getCategoryByIdAll();
}

